package com.bbkb.quartz.util;

import com.bbkb.common.util.bean.BeanConverter;
import com.bbkb.quartz.constants.CommonConstant;
import com.bbkb.quartz.domain.SysJob;
import com.bbkb.quartz.dto.SysJobDTO;
import com.bbkb.quartz.enums.MisfirePolicyEnum;

import java.util.Objects;

/**
 * @作者 沈飞超
 * @功能 转换业务类
 */
public class QuartzConvert {

    public static SysJob sysJobDto2domain(SysJobDTO source) {
        if (Objects.isNull(source)) {
            return null;
        }
        SysJob target = BeanConverter.autoConver(source, SysJob.class);
        return target;
    }

    public static SysJobDTO sysJob2Dto(SysJob source) {
        if (Objects.isNull(source)) {
            return null;
        }
        SysJobDTO target = BeanConverter.autoConver(source, SysJobDTO.class);
        target.setMisfirePolicyStr(MisfirePolicyEnum.getValue(source.getMisfirePolicy()));
        target.setConcurrentStr(CommonConstant.YES == source.getConcurrent() ? "允许" : "禁止");
        target.setStatusStr(CommonConstant.YES == source.getStatus() ? "开启" : "暂停");
        return target;
    }

}
